﻿CREATE TABLE [dbo].[DinnerOrder] (
    [Id]                    INT             IDENTITY (1, 1) NOT NULL,
    [OpenId]                NVARCHAR (50)   NOT NULL,
    [CardType]              INT             NULL,
    [CardNo]                NVARCHAR (50)   NULL,
    [DinnerType]            INT             NULL,
    [OrderDate]             DATETIME        NULL,
    [OrderNo]               NVARCHAR (50)   NULL,
    [TotalMoney]            DECIMAL (18, 2) NULL,
    [Address]               NVARCHAR (2000) NULL,
    [OrderStatus]           INT             NULL,
    [PayStatus]             INT             NULL,
    [RefundReason]          NVARCHAR (50)   NULL,
    [CreateTime]            DATETIME        NULL,
    [PayTime]               DATETIME        NULL,
    [RefundTime]            DATETIME        NULL,
    [NextCheckTime]         DATETIME        NULL,
    [OrderStatusOnSetCheck] INT             NULL,
    [CheckReserved]         NVARCHAR (50)   NULL,
    [BillId]                INT             NULL,
    [WxRefundId]            NVARCHAR (50)   NULL,
    [DinnerDate]            NVARCHAR (50)   NULL,
    [FpId]                  NVARCHAR (50)   NULL,
    [FpName]                NVARCHAR (50)   NULL,
    [HmtId]                 NVARCHAR (50)   NULL,
    [HmtName]               NVARCHAR (50)   NULL,
    [HmtEndTime]            NVARCHAR (50)   NULL,
    [FoodCount]             INT             NULL,
    [FoodAmount]            DECIMAL (18, 2) NULL,
    [DcBillNo]              NVARCHAR (50)   NULL,
    [DeleteStatus]          INT             NULL,
    [PatientName]           NVARCHAR (50)   NULL,
    [WardName]              NVARCHAR (50)   NULL,
    [BedLabel]              NVARCHAR (50)   NULL,
    [WardExtentName]        NVARCHAR (50)   NULL,
    [WardCode]              NVARCHAR (50)   NULL,
    [WardExtentCode]        NVARCHAR (50)   NULL,
    [PatientId]             NVARCHAR (50)   NULL,
    [CardName] NVARCHAR(50) NULL, 
    PRIMARY KEY CLUSTERED ([Id] ASC)
);


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'主键，自增长', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'Id';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'微信用户OpenId', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'OpenId';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'卡类型: 0-诊疗卡1-健康卡 2-市民卡 3-员工卡 4-未知', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'CardType';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'卡号', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'CardNo';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'餐类型，0病人餐1员工餐', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'DinnerType';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'下单时间', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'OrderDate';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'订单号', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'OrderNo';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'订单总金额', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'TotalMoney';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'送餐地点', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'Address';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'订单状态，0未支付 1落单中 2落单失败 3退款中 4退款成功 5退款失败 6落单成功 7微信退餐中 8微信退餐失败 9微信退餐成功 10微信退餐退款中 11微信退餐退款失败 12微信退餐退款成功', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'OrderStatus';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'支付状态:0-未付款,1-已付款,2-退款中,3-已退款，4-退款失败', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'PayStatus';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'退款原因，1-落单失败而退费，2-支付完成时订单已关闭（支付超时）,3-因退餐而退费', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'RefundReason';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'订单创建时间', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'CreateTime';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'支付成功时间', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'PayTime';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'退款成功时间', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'RefundTime';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'系统下次检查时间', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'NextCheckTime';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'(设置系统下次检查时间时)的订单状态', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'OrderStatusOnSetCheck';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'系统检查预留字段', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'CheckReserved';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'DinnerBill.Id', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'BillId';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'微信支付退款单号，退款成功后微信返回', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'WxRefundId';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'送餐日期， yyyy-MM-dd', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'DinnerDate';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'餐牌Id', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'FpId';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'餐牌名称', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'FpName';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'饭点Id', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'HmtId';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'饭点名称', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'HmtName';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'饭点截止时间，HH:mm:ss', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'HmtEndTime';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'菜品总数量', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'FoodCount';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'菜品总金额', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'FoodAmount';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'0-正常，1-已删除', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerOrder', @level2type = N'COLUMN', @level2name = N'DeleteStatus';

